<?php
namespace app\mobile\model;

/**
 * Class Sign
 * @package app\mobile\model 会员签到表
 */
class MemberSign extends BaseModel
{
    public function getSignTimeAttr($value)
    {
        $back = strtotime($value);
        $back = date('d',$back);
        if ($back[0] == 0){
            $back = substr($back,1);
        };
        return $back;
    }
    /*
     * 获取签到日期
     */
    public function getSign($member_id)
    {
        $begin_this_month=date('Y-m-d',mktime(0,0,0,date('m'),1,date('Y')));
        $end_this_month=date('Y-m-d',mktime(23,59,59,date('m'),date('t'),date('Y')));
        //获取会员本月签到的日期
        $arr = $this
            ->where('member_id',$member_id)
            ->where('sign_time','between time',[$begin_this_month,$end_this_month])
            ->select();
        $opt = [];
        foreach ($arr as $v){
            $opt[] = $v['sign_time'];
        }
        return $opt;
    }
}